package string;

public class MatchesDemo {
    public static void main(String[] args) {
        String mail = "fanchuanqi@tedu.cn";
        /*
            邮箱的正则表达式:
            用户名@域名.后缀
            [a-zA-Z0-9_]+@[a-zA-Z0-9]+(\.[a-zA-Z]+)+
         */
        String regex = "[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";

        boolean match = mail.matches(regex);
        if (match) {
            System.out.println("是邮箱");
        } else {
            System.out.println("不是邮箱");
        }

    }
}
